/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test.entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Issam
 */
@Entity
@Table(name = "TRADER", catalog = "", schema = "NETTRADING")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Trader.findAll", query = "SELECT t FROM Trader t"),
    @NamedQuery(name = "Trader.findByMatricule", query = "SELECT t FROM Trader t WHERE t.matricule = :matricule"),
    @NamedQuery(name = "Trader.findByNom", query = "SELECT t FROM Trader t WHERE t.nom = :nom"),
    @NamedQuery(name = "Trader.findByPrenom", query = "SELECT t FROM Trader t WHERE t.prenom = :prenom"),
    @NamedQuery(name = "Trader.findByTelephone", query = "SELECT t FROM Trader t WHERE t.telephone = :telephone"),
    @NamedQuery(name = "Trader.findByDateRecrutement", query = "SELECT t FROM Trader t WHERE t.dateRecrutement = :dateRecrutement")})
public class Trader implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "MATRICULE", nullable = false)
    @GeneratedValue(strategy= GenerationType.AUTO)
    private Short matricule;
    @Basic(optional = false)
    @Column(name = "NOM", nullable = false, length = 20)
    private String nom;
    @Basic(optional = false)
    @Column(name = "PRENOM", nullable = false, length = 20)
    private String prenom;
    @Basic(optional = false)
    @Column(name = "TELEPHONE", nullable = false)
    private int telephone;
    @Basic(optional = false)
    @Column(name = "DATE_RECRUTEMENT", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateRecrutement;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "trader")
    private Collection<TraderGrade> traderGradeCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "matricule")
    private Collection<Client> clientCollection;

    public Trader() {
    }

    public Trader(Short matricule) {
        this.matricule = matricule;
    }

    public Trader(Short matricule, String nom, String prenom, int telephone, Date dateRecrutement) {
        this.matricule = matricule;
        this.nom = nom;
        this.prenom = prenom;
        this.telephone = telephone;
        this.dateRecrutement = dateRecrutement;
    }

    public Short getMatricule() {
        return matricule;
    }

    public void setMatricule(Short matricule) {
        this.matricule = matricule;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getPrenom() {
        return prenom;
    }

    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    public int getTelephone() {
        return telephone;
    }

    public void setTelephone(int telephone) {
        this.telephone = telephone;
    }

    public Date getDateRecrutement() {
        return dateRecrutement;
    }

    public void setDateRecrutement(Date dateRecrutement) {
        this.dateRecrutement = dateRecrutement;
    }

    @XmlTransient
    public Collection<TraderGrade> getTraderGradeCollection() {
        return traderGradeCollection;
    }

    public void setTraderGradeCollection(Collection<TraderGrade> traderGradeCollection) {
        this.traderGradeCollection = traderGradeCollection;
    }

    @XmlTransient
    public Collection<Client> getClientCollection() {
        return clientCollection;
    }

    public void setClientCollection(Collection<Client> clientCollection) {
        this.clientCollection = clientCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (matricule != null ? matricule.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Trader)) {
            return false;
        }
        Trader other = (Trader) object;
        if ((this.matricule == null && other.matricule != null) || (this.matricule != null && !this.matricule.equals(other.matricule))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "test.entities.Trader[ matricule=" + matricule + " ]";
    }
    
}
